unit StringUtil;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls;
  type
       TStringUtil = class
  private
  {}
  public
     class function SplitString(Source, Deli: string ): TStringList;stdcall;
     class function Split(Source, Deli: string ): string;stdcall;
  end;

implementation

class function TStringUtil.SplitString(Source, Deli: string ): TStringList;stdcall;
var
EndOfCurrentString: byte;
StringList:TStringList;
begin
StringList:=TStringList.Create;
while Pos(Deli, Source)>0 do
begin
EndOfCurrentString := Pos(Deli, Source);
StringList.add(Copy(Source, 1, EndOfCurrentString - 1));
Source := Copy(Source, EndOfCurrentString + length(Deli), length(Source) - EndOfCurrentString);
end;
Result := StringList;
StringList.Add(source);
end;

class function TStringUtil.Split(Source, Deli: string ): string;stdcall;
var
EndOfCurrentString: byte;
str:string;
begin

  if Pos(Deli, Source)>0 then
    begin
      EndOfCurrentString := Pos(Deli, Source);
      str := trim(Copy(Source, 1, EndOfCurrentString - 1));
//      showmessage('test '+str);
//Source := Copy(Source, EndOfCurrentString + length(Deli), length(Source) - EndOfCurrentString);
    end
  else
    begin
        str := '';
    end;
    Result := str;
end;
end.
